package com.joymeter.data.entity;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotations.TableName;
import com.joymeter.common.utils.EmptyUtils;

/**
 * @ClassName DeviceInfo
 * @Description TODO
 * 设备信息实体类,数据库device_info表，自定义"时差"字段
 * @Author liang
 * @Date 2018/8/10 16:18
 * @Version 1.0
 **/
@TableName("Device_info")
public class DeviceInfo   {
    private String deviceId;
    private String simId;
    private String gatewayUrl;
    private String gatewayId;
    private String project;
    private String province;
    private String city;
    private String district;
    private String community;
    private String address;
    private String valveState;
    private String deviceState;
    private String simState;
    private String dataUsed;
    private String readState;
    private String updateTime;
    private String diffTime;
    private String readFaile;
    private String category;
    private String deviceProtocol;
    private String valveId;
    private String valveProtocol;



    public boolean isEmpty(){
        if(
        EmptyUtils.isEmpty(deviceId)  ||
        EmptyUtils.isEmpty(gatewayUrl) ||
        EmptyUtils.isEmpty(gatewayId) ||
        EmptyUtils.isEmpty(project) ||
        EmptyUtils.isEmpty(province) ||
        EmptyUtils.isEmpty(city) ||
        EmptyUtils.isEmpty(district) ||
        EmptyUtils.isEmpty(community) ||
        EmptyUtils.isEmpty(address) ||
        EmptyUtils.isEmpty(category) ||
        EmptyUtils.isEmpty(deviceProtocol) ||
        EmptyUtils.isEmpty(valveProtocol) ||
        EmptyUtils.isEmpty(valveId) ){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;

        if(o instanceof DeviceInfo) {
            DeviceInfo localDevice = (DeviceInfo)o;
            if(this.toString().equals(localDevice.toString()))
                return true;
        }
        return false;
    }

    @Override
    public String toString() {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("deviceId",this.deviceId);
        jsonObject.put("simId",this.simId);
        jsonObject.put("gatewayUrl",this.gatewayUrl);
        jsonObject.put("gatewayId",this.gatewayId);
        jsonObject.put("project",this.project);
        jsonObject.put("province",this.province);
        jsonObject.put("city",this.city);
        jsonObject.put("district",this.district);
        jsonObject.put("community",this.community);
        jsonObject.put("address",this.address);
        jsonObject.put("valveState",this.valveState);
        jsonObject.put("deviceState",this.deviceState);
        jsonObject.put("simState",this.simState);
        jsonObject.put("dataUsed",this.dataUsed);
        jsonObject.put("readState",this.readState);
        jsonObject.put("updateTime",this.updateTime);
        jsonObject.put("diffTime",this.diffTime);
        jsonObject.put("readFaile",this.readFaile);
        jsonObject.put("category",this.category);
        jsonObject.put("deviceProtocol",this.deviceProtocol);
        jsonObject.put("valveId",this.valveId);
        jsonObject.put("valveProtocol",this.valveProtocol);
        return jsonObject.toString();
    }

    public DeviceInfo(){}
    /**
     * json转deviceInfo对象
     * @param data
     * @return
     */
    public DeviceInfo (String data){
       super();
       JSONObject jsonObject = JSONObject.parseObject(data);
       this.deviceId = jsonObject.getString("deviceId");
       this.simId = jsonObject.getString("simId");
       this.gatewayUrl = jsonObject.getString("gatewayUrl");
       this.gatewayId = jsonObject.getString("gatewayId");
       this.project = jsonObject.getString("project");
       this.province = jsonObject.getString("province");
       this.city = jsonObject.getString("city");
       this.district = jsonObject.getString("district");
       this.community = jsonObject.getString("community");
       this.address = jsonObject.getString("address");
       this.valveState = jsonObject.getString("valveState");
       this.deviceState = jsonObject.getString("deviceState");
       this.simState = jsonObject.getString("simState");
       this.dataUsed = jsonObject.getString("dataUsed");
       this.readState = jsonObject.getString("readState");
       this.updateTime = jsonObject.getString("updateTime");
       this.diffTime = jsonObject.getString("diffTime");
       this.readFaile = jsonObject.getString("readFaile");
       this.category = jsonObject.getString("category");
       this.deviceProtocol = jsonObject.getString("deviceProtocol");
       this.valveId = jsonObject.getString("valveId");
       this.valveProtocol  = jsonObject.getString("valveProtocol ");
    }



    public String getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }

    public String getSimId() {
        return simId;
    }

    public void setSimId(String simId) {
        this.simId = simId;
    }

    public String getGatewayUrl() {
        return gatewayUrl;
    }

    public void setGatewayUrl(String gatewayUrl) {
        this.gatewayUrl = gatewayUrl;
    }

    public String getGatewayId() {
        return gatewayId;
    }

    public void setGatewayId(String gatewayId) {
        this.gatewayId = gatewayId;
    }

    public String getProject() {
        return project;
    }

    public void setProject(String project) {
        this.project = project;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getDistrict() {
        return district;
    }

    public void setDistrict(String district) {
        this.district = district;
    }

    public String getCommunity() {
        return community;
    }

    public void setCommunity(String community) {
        this.community = community;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getValveState() {
        return valveState;
    }

    public void setValveState(String valveState) {
        this.valveState = valveState;
    }

    public String getDeviceState() {
        return deviceState;
    }

    public void setDeviceState(String deviceState) {
        this.deviceState = deviceState;
    }

    public String getSimState() {
        return simState;
    }

    public void setSimState(String simState) {
        this.simState = simState;
    }

    public String getDataUsed() {
        return dataUsed;
    }

    public void setDataUsed(String dataUsed) {
        this.dataUsed = dataUsed;
    }

    public String getReadState() {
        return readState;
    }

    public void setReadState(String readState) {
        this.readState = readState;
    }

    public String getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(String updateTime) {
        this.updateTime = updateTime;
    }

    public String getDiffTime() {
        return diffTime;
    }

    public void setDiffTime(String diffTime) {
        this.diffTime = diffTime;
    }

    public String getReadFaile() {
        return readFaile;
    }

    public void setReadFaile(String readFaile) {
        this.readFaile = readFaile;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public String getDeviceProtocol() {
        return deviceProtocol;
    }

    public void setDeviceProtocol(String deviceProtocol) {
        this.deviceProtocol = deviceProtocol;
    }

    public String getValveId() {
        return valveId;
    }

    public void setValveId(String valveId) {
        this.valveId = valveId;
    }

    public String getValveProtocol() {
        return valveProtocol;
    }

    public void setValveProtocol(String valveProtocol) {
        this.valveProtocol = valveProtocol;
    }

}
